Ext.define('qjtravel.controller.More', {
    extend: 'Ext.app.Controller',
    requires: ['Ext.data.JsonP'],
    config: {
        refs: {
            more: "more",
            companyInfor: 'more #companyInfor',
            collection: 'more #collection',
            comments: 'more #comments',
            about: 'more #about',
            help: 'more #help',
            protcect: 'more #protcect',
            copyright: 'more #copyright',
            moreshare: 'more #moreshare',

            ProductDetail: 'ProductDetail',
            detail: 'ProductDetail',
            tel: 'ProductDetail #tel'
        },
        control: {
            'collection list': {
                itemtap: function (list, index, element, record) {

                    if (window.localStorage.getItem("controllerClick") == null) {
                        Ext.Viewport.mask({xtype: 'loadmask' });
                        window.localStorage.setItem("controllerClick", '1');
                        var cpid = record.getData().cpid
                        var detail = Ext.getStore('ProductDetail');
                        localStorage.setItem('cpid', record.getData().cpid);
                        localStorage.setItem('isHome', 2);
                        var product_detail = this.getDetail();
                        if (product_detail == null) {
                            product_detail = Ext.create('qjtravel.view.ProductDetail');
                        }
                        var label = product_detail.query('label');
                        Ext.each(label, function (elem) {
                            elem.setData(record.data);
                        });

                        var label = product_detail.query('label');
                        detail.load({
                            params: {cpid: cpid},
                            callback: function (data) {
                                Ext.each(data, function (detail) {
                                    Ext.each(label, function (elem) {
                                        elem.setData(detail.data);
                                    });
                                    Ext.getCmp('toolbars').setTitle(data[0].get('name'));
                                    data[0].get('tel') == ' ' ? Ext.getCmp('tel').hide() : product_detail.query('#tel')[0].setHtml(data[0].get('tel'));
                                    data[0].get('address') == ' ' ? Ext.getCmp('address').hide() : product_detail.query('#address')[0].setHtml(data[0].get('address'));
                                    if (data[0].get('tel') == ' ' && data[0].get('address') == ' ') {
                                        Ext.getCmp('fieldset').hide()
                                    }
                                    product_detail.query('#picurl')[0].setValue(data[0].get('picurl'));
                                    product_detail.query('#explain')[0].setValue(data[0].get('explain'));
                                    product_detail.query('#name')[0].setValue(data[0].get('name'));
                                });
                            }
                        })
                        Ext.Viewport.animateActiveItem(product_detail, {type: 'slide', direction: 'left'});
                    }
                }
            }
        }
    }


})